package com.stylefeng.guns.modular.system.service.impl;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.node.ZTreeNode;
import com.stylefeng.guns.modular.system.dao.FunctionMapper;
import com.stylefeng.guns.modular.system.model.Function;
import com.stylefeng.guns.modular.system.service.IFunctionService;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 系统功能表 服务实现类
 * </p>
 *
 * @author stylefeng
 * @since 2018-08-31
 */
@Service
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED)
public class FunctionServiceImpl extends ServiceImpl<FunctionMapper, Function> implements IFunctionService {

    @Resource
    private FunctionMapper functionMapper;

    /**
     * 获取菜单列表树
     *
     * @return
     * @date 2017年2月19日 下午1:33:51
     */
    @Override
    public List<ZTreeNode> menuTreeList()throws DataAccessException {
        return this.baseMapper.menuTreeList();
    }

    /**
     * 获取菜单列表树
     *
     * @param menuIds
     * @return
     * @date 2017年2月19日 下午1:33:51
     */
    @Override
    public List<ZTreeNode> menuTreeListByMenuIds(List<Long> menuIds)throws DataAccessException {
        return this.baseMapper.menuTreeListByMenuIds(menuIds);
    }
    
    
    @Override
    public int deleteRelationByMenu(Long menuId)throws DataAccessException {
        return this.baseMapper.deleteRelationByMenu(menuId);
    }
    
    @Override
    public List<String> getResUrlsByRoleId(Integer roleId)throws DataAccessException {
        return this.baseMapper.getResUrlsByRoleId(roleId);
    }
    
    @Override
    public List<Function> getMenusByRoleIds(List<String> roleIds,Integer type)throws DataAccessException {
        return this.baseMapper.getMenusByRoleIds(roleIds,type);
    }
    
    @Override
    public List<Function> getMenusByPostIds(List<Integer> postIds,Integer type)throws DataAccessException {
        return this.baseMapper.getMenusByPosts(postIds,type);
    }

    @Override
    public List<Function> selectListFunction(Function sysFunction) throws DataAccessException {
       return  this.functionMapper.selectListFunction(sysFunction);
    }
}
